package com.lanzhou.yuanfen.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lanzhou.yuanfen.sys.entity.Visitor;
import com.lanzhou.yuanfen.vo.CountWeekDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author lcllge
 * @since 2019-12-02
 */
@Mapper
public interface VisitorMapper extends BaseMapper<Visitor> {

    /**
     * 统计数量和点赞
     *
     * @param beginTime
     * @param endTime
     * @return
     */
    @Select("SELECT COUNT(id) idNu, SUM(is_thumb) thumb, DATE(visit_time) visitDate FROM sys_visitor WHERE visit_time <= #{endTime} AND visit_time >= #{beginTime} GROUP BY DATE(visit_time) ORDER BY visitDate DESC")
    List<CountWeekDTO> countWeek(@Param("beginTime") String beginTime, @Param("endTime") String endTime);
}
